﻿
var g_arrEXCHANGE = new Array(
        new Array("HOSTC", "HOSE"),
        new Array("HASTC", "HNX"),
        new Array("VPOTC", "UPCOM"))
var g_arrEXCHANGE2 = new Array(
        new Array(1, "HOSE"),
        new Array(2, "HNX.NY"),
        new Array(3, "HNX.UPCOM"))
		
function $$(id) { return document.getElementById(id); }
// string
function Left(ax, n) { if (n <= 0) return ""; else if (n > String(ax).length) return ax; else return String(ax).substring(0, n); };
function Right(ax, n) { if (n <= 0) return ""; else if (n > String(ax).length) return ax; else { var ao = String(ax).length; return String(ax).substring(ao, ao - n); } }
function Trim(iStr) { while (iStr.charCodeAt(0) <= 32) { iStr = iStr.substr(1); } while (iStr.charCodeAt(iStr.length - 1) <= 32) { iStr = iStr.substr(0, iStr.length - 1); } return iStr; }
function TrimAll(t) { while (t.value.indexOf(' ') != -1) { t.value = t.value.replace(' ', ''); } }
function TrimSTR(s) { var l = 0; var r = s.length - 1; while (l < s.length && s[l] == ' ') { l++; } while (r > l && s[r] == ' ') { r -= 1; } return s.substring(l, r + 1); }


//nhom lenh, send server
function EzTrade_InitAutoComplete() {
    //alert(g_Language)vi-VN/en
    var arr1 = g_arrStockInfo; // ['a', 'b', 'c'];
    var arr2 = [];

    for (var i = 1; i < arr1.length; i++) {
        var vExchange = GetExchangeText2(arr1[i][1]);
        var vName = '';
        vName = arr1[i][2];        
        arr2[i] = arr1[i][0] + ' - ' + vExchange + ' - ' + vName;
    }

    menu = new InputSuggestions({
        inputID: 'ticker',
        list: arr2,
        maxItems: 10 // suggestion box remains hidden until the filtered list contains this number of items or fewer
    });

    menu.initialize();
}

// 1 => HOSE; 2=>HNX.NY; 3=>HNX.UPCOM
function GetExchangeText2(vNo) {
    for (var i = 0; i < g_arrEXCHANGE.length; i++) {
        if (vNo == g_arrEXCHANGE2[i][0])
            return g_arrEXCHANGE2[i][1];
    }

    return vNo;
}



var g_arrStockInfo = [];